
import { useRef, useEffect } from "react";
import { EchartsHandle } from "taro-react-echarts";
import { BaseEchartProps } from "./type";
import * as echarts from "echarts";

function useBaseEchart(props: BaseEchartProps) {
  const { option = {} } = props;

  const echartsRef = useRef<EchartsHandle>(null);

  // useEffect(() => {
  //   let keys = Object.keys(option);
  //   if (keys.length) {
  //     // if (echartsRef.current) echartsRef.current = null
  //     // echartsRef.current = echarts.init(echartsRef.current)
  //     // echartsRef.current.setOption(option)
  //   }
  // }, [option]);

  return {
    echartsRef,
  };
}

export default useBaseEchart;
